The constructor for the file_lock class accepts the name of the file to be locked, and it's important to open the file before lock is invoked; otherwise, an exception will be thrown. filelock类的构造函数接受要锁定的文件的名称,一定要在调用lock之前打开文件;否则会抛出异常。
If the method annotated with@ Synchronized is static, Lombok automatically creates a class object called$ LOCK and synchronizes the method against that object. 如果用@Synchronized注释的这个方法是静态的,那么Lombok就会创建一个名为$LOCK的类对象,并会针对该对象同步这个方法。
A class loader deadlock occurs when two threads each own a lock on two different class loaders, and both threads are waiting for the lock owned by the other thread. 当两个线程在两个不同的类装入器上都拥有各自的锁,同时又都等候对方拥有的锁的时候,就会发生类装入器死锁。